package scau.zxck.view.stage;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import scau.zxck.utils.PropUtil;

public class AlertStage extends Stage {

	private VBox vBox = new VBox(10);
	private HBox hBox = new HBox();
	private Label label = new Label();
	private Button btOk = new Button("OK");

	public AlertStage (String message) {
		this(PropUtil.getBasicProp("Software_Name"), message);
	}

	public AlertStage(String tittle, String message) {
		label.setText(message);
		label.setWrapText(true);
		vBox.setPrefSize(225, 75);
		hBox.setAlignment(Pos.CENTER);
		hBox.getChildren().addAll(label);
		vBox.getChildren().add(hBox);
		vBox.getChildren().add(btOk);
		vBox.setAlignment(Pos.CENTER);
		btOk.setPrefSize(45, 25);
		btOk.setFocusTraversable(false);
		btOk.setCursor(Cursor.HAND);
		Scene scene = new Scene(vBox);

		btOk.setOnAction(new EventHandler<ActionEvent>() {
			public void handle(ActionEvent actionEvent) {
				close();
			}
		});
		this.getIcons().add((new Image("image/zxck_logo.png")));
		this.centerOnScreen();
		this.setScene(scene);
		this.setResizable(false);
		this.setTitle(tittle);
		this.setAlwaysOnTop(true);
	}
}
